package com.jp.knowledge.activity;

import android.widget.TextView;

import com.jiayen.cache.FileCacheManager;
import com.jp.knowledge.R;
import com.jp.knowledge.comm.SlidingActivity;

import org.xutils.view.annotation.ViewInject;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class CrashActivity extends SlidingActivity {


    @ViewInject(R.id.exception_msg)
    private TextView   msg;

    private FileCacheManager  cacheManager;
    public String exceptionPath;
    @Override
    protected int getResourceId() {
        return R.layout.activity_crash;
    }

    @Override
    protected void init() {
        exceptionPath=mContext.getCacheDir()+"/exception_" + ".dat";//错误日志缓存缓存路径
        cacheManager = new FileCacheManager();
        Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(Subscriber<? super String> subscriber) {
                Object bannerData = cacheManager.readObject(exceptionPath);
                subscriber.onNext((String)bannerData);
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<String>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                    }

                    @Override
                    public void onNext(String  data) {
                        msg.setText(data);
                    }
                });
    }
}
